package com.design.proxy.dynamic;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;

/**
 * @ClassName Client.java
 * @Description
 * @author Jon
 * @date 2018年6月14日 下午1:58:07
 */
public class Client {

	public static void main(String[] args) {
		//定义一个玩家
		IGamePlayer play = new GamePlayer("jon");
		//定义一个handel
		InvocationHandler handler = new GamePlayH(play);
		//获取目标对象类的ClassLoader
		ClassLoader classLoader = play.getClass().getClassLoader();
		//动态产生一个代理者
		IGamePlayer proxy = (IGamePlayer) Proxy.newProxyInstance(classLoader, 
				new Class[]{IGamePlayer.class}, handler);
		proxy.login("皇帝风暴", "123456");
		proxy.killBoss();
		proxy.upgrade();
	}

}
